Subject: Processor Ids
From: "Barry D. Wills" <[email-masked]>
To: "amigae" <[email-masked]>
Date: 11 Jul 93 09:52:00 CST

Here's something I cooked up to help my startup-sequence in deciding which
startup to run based on the processor I booted with (Derringer-030 uses 68000
and 68030).  It also checks for FPU and MMU just for the heck of it.
----- CUT HERE ----------------------------------------------------------------
/*
  IdentifyProcessors - For AmigaDOS V1.3 (and higher?)
  Author:  Barry Wills

  Program to place the values of the current processor ids in the
  environment.  The following environment variables will receive the
  appropriate string values, and can be used in scripts:

  $CPU - 68040
         68030
         68020
         68010
         68000
  $FPU - 68882
         68881
         NIL     (usage:  IF "$FPU" eq "")
  $MMU - 68851
         NIL     (usage:  IF "$MMU" eq "")

  Configuration Notes (add your config and results here)
  ~~~~~~~~~~~~~~~~~~~
  KS1.3: - 68000/""/""       == correct values reflected
           68030/68881/68851 == (Derringer-030)  MMU not recognized

  Rights and Restrictions
  ~~~~~~~~~~~~~~~~~~~~~~~
  This program is hereby placed in the public domain.  The reader/user of
  this program assumes all risk.

*/

MODULE 'exec/types'
MODULE 'exec/execbase'
MODULE 'dos/dos'

DEF ver = NIL

PROC main ()
  DEF execBase : PTR TO execbase,
      attnFlag,
      processor,
      fh

   ver := 'VER$: PROCs V1.0 (10JUL93)'

   execBase := execbase
   attnFlag := execBase.attnflags

   /*-----------------*/
   /* Check CPU type. */
   /*-----------------*/

   IF attnFlag AND AFF_68040
     processor := '68040'
   ELSEIF attnFlag AND AFF_68030
     processor := '68030'
   ELSEIF attnFlag AND AFF_68020
     processor := '68020'
   ELSEIF attnFlag AND AFF_68010
     processor := '68010'
   ELSE
     processor := '68000'
   ENDIF

   IF (fh := Open ('ENV:CPU', NEWFILE)) = NIL THEN RETURN RETURN_FAIL
   Write (fh, processor, 5)
   Close (fh)

   /*----------------*/
   /* Check for FPU. */
   /*----------------*/

   IF attnFlag AND AFF_68881
     processor := '68881'
   ELSEIF attnFlag AND AFF_68882
     processor := '68882'
   ELSE
     processor := NIL
   ENDIF

   IF (fh := Open ('ENV:FPU', NEWFILE)) = NIL THEN RETURN RETURN_FAIL
   IF processor THEN Write(fh, processor, 5)
   Close (fh)

   /*----------------*/
   /* Check for MMU. */
   /*----------------*/

   IF attnFlag AND AFF_68851_MMU
     processor := '68851'
   ELSE
     processor := NIL
   ENDIF

   IF (fh := Open ('ENV:MMU', NEWFILE)) = NIL THEN RETURN RETURN_FAIL
   IF processor THEN Write (fh, processor, 5)
   Close (fh)

ENDPROC  0